package com.fancy.learncenter.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.fancy.learncenter.R;
import com.fancy.learncenter.bean.CartoonContructSatisticsesBean;
import com.fancy.learncenter.common.JumpIntentKey;
import com.fancy.learncenter.ui.activity.CartoonQuestionTypeActivity;
import com.fancy.learncenter.ui.activity.CartoonWorkQuestionTypeActivity;
import com.fancy.learncenter.ui.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.ui.adapter.base.CustomViewHold;

import java.util.List;

/**
 * Created by shiweiwei on 2018/1/4.
 */

public class CartoonErrorKindsAdapter extends CommonRecycleViewAdapter<CartoonContructSatisticsesBean> {

    String unitId;
    String homePackageId;

    public CartoonErrorKindsAdapter(Context mContext, List<CartoonContructSatisticsesBean> itemDatas, String unitId, String homePackageId) {
        super(mContext, R.layout.cartoon_error_kinds_item, itemDatas);
        this.unitId = unitId;
        this.homePackageId = homePackageId;
    }

    @Override
    public void bindView(CustomViewHold customViewHold, final CartoonContructSatisticsesBean item, int position) {

        TextView error_kinds_name = customViewHold.getView(R.id.error_kinds_name);
        TextView error_kinds_num = customViewHold.getView(R.id.error_kinds_num);
        if (!TextUtils.isEmpty(item.getConstructName())) {
            error_kinds_name.setText(item.getConstructName());
        }
        if (!TextUtils.isEmpty(item.getWrongNums())) {
            error_kinds_num.setText(item.getWrongNums() + "题");
        }

        if (!"0".equals(item.getWrongNums())) {
            customViewHold.getRoorView().setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Bundle bundle = new Bundle();
                    bundle.putString(JumpIntentKey.CONSTRUCTID, item.getConstructId());
                    bundle.putSerializable(JumpIntentKey.QUESTION_ENTER, JumpIntentKey.QUESTION_ENTER_TYPE.ERROR_KINDS);
                    bundle.putString(JumpIntentKey.UNIT_ID, unitId);
                    bundle.putString(JumpIntentKey.HOMEWORK_PACKAGE_ID, homePackageId);
//                    Intent intent = new Intent(mContext, CartoonQuestionTypeActivity.class);
                    Intent intent = new Intent(mContext, CartoonWorkQuestionTypeActivity.class);
                    intent.putExtras(bundle);
                    mContext.startActivity(intent);
                }
            });
        }

    }

}
